home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / keyb / toggle.zip / TOGGLE.ASM < prev    next >
Assembly Source File  |  1986-10-06  |  4KB  |  189 lines

  1.     if1
  2.     %out    TOGGLE.ASM
  3.     endif
  4.     if2
  5.     %out    *** PASS 2
  6.     endif
  7.     name    TOGGLE
  8.     title    TOGGLE
  9.     page    ,132
  10.  
  11. ; ************************************************************************
  12. ; **                                    **
  13. ; ** filename:    toggle.asm                        **
  14. ; **                                    **
  15. ; **    Provides an MS-DOS utility to control CAPS LOCK, NUM LOCK, and    **
  16. ; ** SCROLL LOCK.                            **
  17. ; **                                    **
  18. ; ************************************************************************
  19.  
  20. code    segment
  21.  
  22.     assume    cs:code,ds:code,es:code
  23.  
  24.     org    100H
  25.  
  26. toggle    proc    far
  27.  
  28.     push    ds            ;
  29.     pop    di            ; store data segment register
  30.     mov    ax,0            ;
  31.     push    ax            ;
  32.     pop    ds            ; point data segment to paragraph 0
  33.     mov    bx,0417H        ; point to shift status byte
  34.     mov    si,80H            ; point to parameter count
  35.     mov    cl,cs:[si]        ; load parameter count
  36.     mov    ch,0            ; cx = paramter count
  37.     add    si,2            ; point to parameters
  38.     dec    cx            ; adjust counter - done?
  39.  
  40. find_slash:
  41.     jcxz    done            ; yes - terminate
  42.  
  43.     mov    al,cs:[si]        ; no - load character
  44.     inc    si            ; point to next character
  45.     dec    cx            ; retard counter
  46.     cmp    al,'/'            ; slash?
  47.     jne    find_slash        ; no - continue
  48.  
  49. find_cmd:
  50.     jcxz    done            ; done? - yes - terminate
  51.  
  52.     mov    al,cs:[si]        ; no - load character
  53.     inc    si            ; point to next character
  54.     dec    cx            ; retard counter
  55.     and    al,not('a' xor 'A')    ; convert character to upper case
  56.     cmp    al,'C'            ; C?
  57.     jne    find_cmd_05        ; no - test for N
  58.  
  59.     jmp    C_switch        ; yes - determine CAPS ON or OFF
  60.  
  61. find_cmd_05:
  62.     cmp    al,'N'            ; N?
  63.     jne    find_cmd_10        ; no - test for S
  64.  
  65.     jmp    N_switch        ; yes - determine NUM ON or OFF
  66.  
  67. find_cmd_10:
  68.     cmp    al,'S'            ; S?
  69.     jne    find_slash        ; no - find slash
  70.  
  71.     jmp    S_switch        ; no - determine SCROLL ON or OFF
  72.  
  73. C_switch:
  74.     jcxz    done            ; end of paramters? - yes - done
  75.  
  76.     mov    al,cs:[si]        ; no - load character
  77.     inc    si            ; point to next character
  78.     dec    cx            ; retard counter
  79.     cmp    al,'+'            ; +?
  80.     jne    C_switch_05        ; no - test for -
  81.  
  82.     call    caps_on            ; yes - turn on CAPS
  83.     jmp    find_slash        ; continue
  84.  
  85. C_switch_05:
  86.     cmp    al,'-'            ; -?
  87.     je    C_switch_10        ; yes - turn off CAPS
  88.  
  89.     jmp    find_slash        ; no - continue
  90.  
  91. C_switch_10:
  92.     call    caps_off        ; yes - turn off CAPS
  93.     jmp    find_slash        ; continue
  94.  
  95. N_switch:
  96.     jcxz    done            ; end of paramters? - yes - done
  97.  
  98.     mov    al,cs:[si]        ; no - load character
  99.     inc    si            ; point to next character
  100.     dec    cx            ; retard counter
  101.     cmp    al,'+'            ; +?
  102.     jne    N_switch_05        ; no - test for -
  103.  
  104.     call    num_on            ; yes - turn on NUM
  105.     jmp    find_slash        ; continue
  106.  
  107. N_switch_05:
  108.     cmp    al,'-'            ; -?
  109.     je    N_switch_10        ; yes - turn off NUM
  110.  
  111.     jmp    find_slash        ; no - continue
  112.  
  113. N_switch_10:
  114.     call    num_off            ; yes - turn off NUM
  115.     jmp    find_slash        ; continue
  116.  
  117. S_switch:
  118.     jcxz    done            ; end of paramters? - yes - done
  119.  
  120.     mov    al,cs:[si]        ; no - load character
  121.     inc    si            ; point to next character
  122.     dec    cx            ; retard counter
  123.     cmp    al,'+'            ; +?
  124.     jne    S_switch_05        ; no - test for -
  125.  
  126.     call    scroll_on        ; yes - turn on SCROLL
  127.     jmp    find_slash        ; continue
  128.  
  129. S_switch_05:
  130.     cmp    al,'-'            ; -?
  131.     je    S_switch_10        ; yes - turn off SCROLL
  132.  
  133.     jmp    find_slash        ; no - continue
  134.  
  135. S_switch_10:
  136.     call    scroll_off        ; yes - turn off SCROLL
  137.     jmp    find_slash        ; continue
  138.  
  139. done:
  140.     push    di            ;
  141.     pop    ds            ; restore data segment register
  142.     int    20H            ; return to DOS
  143.  
  144. toggle    endp
  145.     page
  146. subs    proc    near
  147.  
  148. caps_on:
  149.     mov    al,[bx]            ; load shift status byte
  150.     or    al,01000000B        ; turn CAPS LOCK on
  151.     mov    [bx],al            ; store shift status byte
  152.     ret                ;
  153.  
  154. caps_off:
  155.     mov    al,[bx]            ; load shift status byte
  156.     and    al,10111111B        ; turn CAPS LOCK off
  157.     mov    [bx],al            ; store shift status byte
  158.     ret                ;
  159.  
  160. num_on:
  161.     mov    al,[bx]            ; load shift status byte
  162.     or    al,00100000B        ; turn NUM LOCK on
  163.     mov    [bx],al            ; store shift status byte
  164.     ret                ;
  165.  
  166. num_off:
  167.     mov    al,[bx]            ; load shift status byte
  168.     and    al,11011111B        ; turn NUM LOCK off
  169.     mov    [bx],al            ; store shift status byte
  170.     ret                ;
  171.  
  172. scroll_on:
  173.     mov    al,[bx]            ; load shift status byte
  174.     or    al,00010000B        ; turn SCROLL LOCK on
  175.     mov    [bx],al            ; store shift status byte
  176.     ret                ;
  177.  
  178. scroll_off:
  179.     mov    al,[bx]            ; load shift status byte
  180.     and    al,11101111B        ; turn SCROLL LOCK off
  181.     mov    [bx],al            ; store shift status byte
  182.     ret                ;
  183.  
  184. subs    endp
  185.  
  186. code    ends
  187.  
  188.     end    toggle
  189.